define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'system/gameversion/index',
                    add_url: 'system/gameversion/add',
                    edit_url: 'system/gameversion/edit',
                    del_url: 'system/gameversion/del',
                    multi_url: 'system/gameversion/multi',
                    table: 'v_version',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortOrder: 'id',
                columns: [
                    [
                        {checkbox: true},
						{field: 'caption', title: __('Caption')},
						{field: 'appversion', title: __('Appversion')},
						{field: 'androidversion', title: __('Androidversion')},
                        {field: 'versionid', title: __('Versionid')},
                        {field: 'bsize', title: __('Bsize'), operate: '>=', placeholder: '大于等于数值'},
                        {field: 'upcontent', title: __('Upcontent'), operate: 'LIKE %...%', placeholder: '模糊搜索，*表示任意字符'},
                        {field: 'linkurl', title: __('Linkurl'), formatter: Table.api.formatter.url, operate: false},
						{field: 'apklinkurl', title: __('Apklinkurl'), formatter: Table.api.formatter.url, operate: false},
						{field: 'ipalinkurl', title: __('Ipalinkurl'), formatter: Table.api.formatter.url, operate: false},
                        {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        {field: 'updatatime', title: __('Updatatime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange'},
                        {field: 'status', title: __('Status'), searchList: {'expired':__('expired'), 'notstart':__('notstart'),'geton':__('geton')}, style: 'min-width:100px;'},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});